package com.bootcamp.javase.file;

import javax.lang.model.element.VariableElement;
import java.util.Scanner;

/**
 * @program: FIleCode
 * @description:
 * @author: Keyu Li
 * @create: 2021-09-08 14:02
 **/

public class ScannerUtils {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        System.out.println(getValidIntInput());
    }

    public static int getValidIntInput(){
        int value = 0;
        while (true){
            System.out.print("请输入一个整数： ");
            try {
                value = Integer.parseInt(sc.nextLine());
            }catch (NumberFormatException e){
                continue;
            }
            return value;
        }
    }
}
